package com.test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO(这里用一句话描述这个类的作用)
 *
 * @author liuqinghua
 * @date 2025-8-5
 */

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.converters.string.StringImageConverter;
import com.alibaba.excel.converters.url.UrlImageConverter;

import lombok.AllArgsConstructor;
import lombok.Data;

public class ImageExportDemo {
    public static void main(String[] args) throws MalformedURLException {
        List<ImageData> data = new ArrayList<>();
        data.add(new ImageData(new URL("http://172.16.127.76:9000/fbs/111.png"), "d:/word/111.png", "张三"));
        data.add(new ImageData(new URL("http://172.16.127.76:9000/fbs/111.png"), "d:/word/111.png", "王五\n123"));

        EasyExcel.write("d:/word/output.xlsx", ImageData.class).sheet("图片导出").doWrite(data);
    }

    @AllArgsConstructor
    @Data
    public static class ImageData {
        @ExcelProperty(value = "图片", converter = UrlImageConverter.class)
        private URL image;

        @ExcelProperty(value = "图片2", converter = StringImageConverter.class)
        private String image2;

        @ExcelProperty(value = "姓名")
        private String name;
    }
}
